<template>
	<view class="confirm-order bg-active-color">
		<Lines></Lines>
		<!-- 地址 -->
		<view class="order-map" @tap="gotoPathList">
			<template v-if="path">
				<view class="map-title">
					<view class="map-name">收件人：{{path.name}}</view>
					<view>{{path.tel}}</view>
				</view>
				<view class="map-city">{{path.city}} {{path.details}}</view>
			</template>
			<template v-else>
				<view class="map-title">
					<view class="map-name">请选择默认地址</view>
				</view>
			</template>
		</view>
		<!-- 商品 -->
		<view class="goods-list">
			<view class="goods-item">
				<image class="goods-img" src="../../static/img/goods3.jpg" mode=""></image>
				<view class="goods-text">
					<view class="goods-name">商品名称,茶，茶，商品名称,茶，茶</view>
					<view  class="content">颜色分类:黑色</view>
					<view class="f-active-color" style="font-size: 24rpx;">七天无理由退货</view>
				</view>
				<view style="font-size: 26rpx;">
					<view>￥399.9</view>
					<view class="f-color">*1</view>
				</view>
			</view>
			<view class="goods-item">
				<image class="goods-img" src="../../static/img/goods3.jpg" mode=""></image>
				<view class="goods-text">
					<view class="goods-name">商品名称,茶，茶，商品名称,茶，茶</view>
					<view  class="content">颜色分类:黑色</view>
					<view class="f-active-color" style="font-size: 24rpx;">七天无理由退货</view>
				</view>
				<view style="font-size: 26rpx;">
					<view>￥399.9</view>
					<view class="f-color">*1</view>
				</view>
			</view>
		</view>
		
		<!-- 合计，底部订单 -->
		<view class="order-foot">
			<view class="foot-price">
				合计:<text class="f-active-color">399.9</text>
			</view>
			<view class="">
				<view class="confirm" @tap="goPayment">
					提交订单
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Lines from '../../components/common/Lines.vue'
	import {mapGetters} from 'vuex'
	export default {
		data() {
			return {
				//存放默认地址
				path:false
			}
		},
		components:{
			Lines
		},
		computed:{
			...mapGetters(['defaultPath']),
		},
		onLoad() {
			//如果有默认地址，则进行赋值
			if(this.defaultPath.length){
				this.path = this.defaultPath[0];
			}
			//如果触发自定义事件，on去接收数据
			uni.$on("selectPathItem",(res =>{
				//将选择的地址赋值给订单地址
				console.log(res);
				this.path = res;
			})
			)
		},
		onUnload(){
			uni.$off("selectPathItem",()=>{
				console.log("移除了");
			})
		},
		methods: {
			gotoPathList() {
				uni.navigateTo({
					url:'../my-path-list/my-path-list?type=selectPath'
				})
			},
			goPayment() {
				uni.navigateTo({
					url:'../payment/payment'
				})
			}
		}
	}
</script>

<style scoped>
.confirm-order {
	/* 占满屏幕，代替获取可视高度 */
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	width: 100%;
	height: 100%;
}
.goods-list {
	margin-top: 30rpx;
	background-color: #FFFFFF;
}
.goods-item {
	margin: 20rpx 0;
	background-color: #F7F7F7;
	margin-top: 30rpx;
	padding: 10rpx 20rpx;
	display: flex ;
	justify-content: space-between;
	align-items: center;
}
.order-map {
	padding: 20rpx 20rpx;
	background-color: #FFFFFF;
	line-height: 40rpx;
}
.map-title {
	display: flex;
	justify-content: space-between;
}
.map-name {
	/* font-size: 26rpx;
	font-weight: bold; */
}
.goods-text {
	width: 360rpx;
	padding: 0 10rpx;
	font-size: 26rpx;
}
.content {
	font-size: 24rpx;
	color: #636263;
}
.goods-img {
	width: 200rpx;
	height: 200rpx;
}

/* 底部样式 */
.order-foot {
	width: 100%;
	height: 80rpx;
	position: fixed;
	bottom: 0;
	left: 0;
	background-color: #FFFFFF;
	display: flex;
	justify-content:flex-end;
	align-items: center;
}
.confirm {
	margin-left: 20rpx;
	color: #FFFFFF;
	background-color: #49BDFB;
	padding: 10rpx 30rpx;
}
</style>
